package com.school.controller;


import com.school.domain.dto.PhonePwdLoginDTO;
import com.school.domain.dto.UserNamePwdLoginDTO;
import com.school.domain.dto.UserRegisterDTO;
import com.school.domain.vo.Result;
import com.school.domain.vo.user.UserLoginVO;
import com.school.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author Forever
 * @since 2025-07-05
 */
@RestController
@RequestMapping("/user")
@Tag(name = "用户信息表 接口")
public class UserController {

    @Resource
    private UserService userService;

    @Operation(summary = "用户名登录")
    @PostMapping("/loginByUserName")
    public Result<UserLoginVO> loginByUserName(@RequestBody UserNamePwdLoginDTO login) {
        return Result.success(userService.loginByUserName(login));
    }

    @Operation(summary = "手机号登录")
    @PostMapping("/loginByPhone")
    public Result<UserLoginVO> loginByPhone(@RequestBody PhonePwdLoginDTO login) {
        return Result.success(userService.loginByPhone(login));
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册，只能内部用户添加")
    public Result<String> UserRegister(@RequestBody UserRegisterDTO register) {
        return Result.success(userService.userRegister(register));
    }

}

